package com.example.yls.demoa;

import android.database.Cursor;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
     private Button BtnSearchDemobstulist;
     private StringBuffer buffer = new StringBuffer();
    private EditText edtNo ;
    private EditText edtAge ;
    private EditText edtName ;
    private EditText btnAdd ;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        BtnSearchDemobstulist = findViewById(R.id.btn_search_Frome_Demob);
        BtnSearchDemobstulist.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Uri uri = Uri.parse("content://com.gdcp.student/student");
                Cursor cursor = getContentResolver().query(uri, null, null, null, null);

                if(cursor != null && cursor.getCount() > 0){

                    for(cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()){
                        String stuno = cursor.getString(0);
                        String name = cursor.getString(1);
                        int age = cursor.getInt(2);
                        buffer.append(stuno).append("  ").append(name).append("  ").append(age).append("\n");

                    }


                }

            }
        });
        edtNo = findViewById(R.id.btn_add_stuo);
        edtName = findViewById(R.id.btn_add_stuname);
        edtAge = findViewById(R.id.btn_add_stuage);



    }
}
